﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Rule
{
    public class TitleImageTemplateRule : TemplateRule
    {
        private string image;

        public string Image
        {
            get { return image; }
            set { image = value; }
        }

        private float threshold = 0.9f;

        public float Threshold
        {
            get { return threshold; }
            set { threshold = value; }
        }

        public override bool parseFromXmlNode(System.Xml.XmlNode node)
        {
            return base.parseFromXmlNode(node);
        }

        public override bool match(string fileName)
        {
            if (string.IsNullOrWhiteSpace(fileName))
                return false;

            double value = 0.0;

            int res = SizeMathFileHeaderName(image, fileName, ref value);
            
            return value <= threshold;
        }

        [DllImport("DocRec.dll", EntryPoint = "SizeMathFileHeaderName")]
        public static extern int SizeMathFileHeaderName([MarshalAs(UnmanagedType.LPStr)] string objectName,
            [MarshalAs(UnmanagedType.LPStr)] string sceneName, ref double value);
    }
}
